﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using CommunitySystem.CanGongService;

namespace CommunitySystem
{
    public partial class Can : ChildWindow
    {
        public DateTime? Dt = null;
        public int ID;
        public string Type;
        public CanGongModel Model = new CanGongModel();
        public CanGongService.CanGongServiceClient client = new CanGongServiceClient();

        public Can(CanGongModel model)
        {
            InitializeComponent();
            Model = model;
            client.UpdateCheGaiStatusCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(client_UpdateCheGaiStatusCompleted);
        }

        void client_UpdateCheGaiStatusCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            SilverlightMessageBoxLibrary.Message.InfoMessage("确认成功！");
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(riqi.Text) || Convert.ToDateTime(riqi.Text) == Convert.ToDateTime("1900-01-01"))
            {
                SilverlightMessageBoxLibrary.Message.ErrorMessage("请填写确认日期！");
                return;
            }
                Dt = Convert.ToDateTime(riqi.Text);
                client.UpdateCheGaiStatusAsync(Model.ID, "确认", Dt, Model.Name);
            

        }
    }
}
